# -*- coding: UTF-8 -*-
#!/usr/bin/env python

import urllib2
import urllib
import traceback

def geturl(url):
	try:
		conn = urllib2.urlopen(url,timeout=5)
		html = conn.read()
		return html
	except urllib2.URLError:
		return ''

def geturl(url,send_headers):
	try:
		req = urllib2.Request(url,headers=send_headers)
		conn = urllib2.urlopen(req)
		html = conn.read()
		return html
	except urllib2.URLError:
		traceback.print_exc()
		return ''

def posturl(url, data,send_headers):
	req = urllib2.Request(url,headers=send_headers) 
	data = urllib.urlencode(data)
	opener = urllib2.build_opener(urllib2.HTTPCookieProcessor()) 
	response = opener.open(req, data) 
	return response.read()